const urlLogin = "/zjfAuthUserInfo/login"
const urlAdd = "/zjfAuthUserInfo/add"

customerClickToSelect = false;

$(function () {
    // jq初始化
    if (navigator.appName == 'Microsoft Internet Explorer') {
        if (navigator.userAgent.indexOf("MSIE 5.0") > 0 || navigator.userAgent.indexOf("MSIE 6.0") > 0 || navigator.userAgent.indexOf("MSIE 7.0") > 0) {
            alert('您使用的 IE 浏览器版本过低, 推荐使用 Chrome 浏览器或 IE8 及以上版本浏览器.');
        }
    }
    // 初始化的时候,把样式加上
    $("html").addClass("bg-dark js no-touch no-android no-chrome no-firefox no-iemobile no-ie no-ie10 no-ie11 no-ios no-ios7 ipad");

});

function login() {
    let user = $("#user").val().trim();
    let pass = $("#pass").val().trim();

    let u = StringUtil.isEmpty(user);
    let p = StringUtil.isEmpty(pass);
    if (u || p) {
        errorMsg("用户名/者密码不能为空!!!", type.DANGER)
        return;
    }

    let configParam = {
        "USER": user,
        "PASS": hex_md5(pass).toString().toUpperCase()
    };
    ajax(urlLogin, configParam, true , 1);
}
function showRegister() {
    $("#registerBtn").css("display", "inline-block");
    $("#cancelBtn").css("display", "inline-block");
    $("#loginBtn").css("display", "none");
    $("#showRegisterBtn").css("display", "none");

    $("#groupName").removeAttr("hidden");
    $("#groupPhone").removeAttr("hidden");

    clearRegisterInfo();

    $("#titleText").text("用户注册")
}
function hiddenRegister() {

    $("#registerBtn").css("display", "none");
    $("#cancelBtn").css("display", "none");
    $("#loginBtn").css("display", "inline-block");
    $("#showRegisterBtn").css("display", "inline-block");

    $("#groupName").attr("hidden","hidden");
    $("#groupPhone").attr("hidden","hidden");

    clearRegisterInfo();
    $("#titleText").text("用户登陆")
}

function clearRegisterInfo() {
    $("#name").val("");
    $("#user").val("");
    $("#pass").val("");
    $("#phone").val("");
}

// 点击注册
function register() {
    let name =  $("#name").val().trim();
    let user =  $("#user").val().trim();
    let pass =  $("#pass").val().trim();
    let phone = $("#phone").val().trim();

    let n = StringUtil.isEmpty(name);
    let u = StringUtil.isEmpty(user);
    let p = StringUtil.isEmpty(pass);
    if (n || u || p) {
        errorMsg("姓名/用户名/密码不能为空!!!", type.DANGER)
        return;
    }

    let param = {
        "NAME": name,
        "USER": user,
        "PASS": hex_md5(pass).toString().toUpperCase(),
        "PHONE": phone
    };

    ajax(urlAdd, param, false );
    hiddenRegister();
}


function getCustomerParam() {

}
function customerInitBtn() {

}